package at.ac.tuwien.dse.health.dashboard;

import at.ac.tuwien.dse.health.dashboard.dto.Notification;
import at.ac.tuwien.dse.health.security.Secured;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.inject.Inject;
import java.util.List;

import static com.google.common.collect.Lists.transform;

/**
 * @author Bernhard Nickel
 * @author Gregor Schauer
 * @author Dominik Strasser
 */
@Controller
@RequestMapping("/notification")
public class NotificationController {
	@Inject
	HealthService service;

	@RequestMapping("/check")
	@ResponseBody
	@Secured
	public List<Notification> getNotifications() {
		return transform(service.getUnreadMessages(), new HealthService.MessageMappingFunction());
	}
}
